package com.work.intelligent_transportation2.fragment;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.work.intelligent_transportation2.R;

import java.util.List;
import Api.TrafficLIghts_api;
public class TrafficLights_Apadt extends RecyclerView.Adapter<TrafficLights_Apadt.TrafficLights> {
    private List<TrafficLIghts_api>list;
    public TrafficLights_Apadt(List<TrafficLIghts_api> list) {
        this.list = list;
    }
    @NonNull
    @Override
    public TrafficLights onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view=View.inflate(parent.getContext(), R.layout.traffic_apdat,null);
        return new TrafficLights(view);
    }

    @Override
    public void onBindViewHolder(@NonNull TrafficLights holder, int position) {
        TrafficLIghts_api trafficLIghts_api=list.get(position);
        String i=String.valueOf(position+1);
//        holder.te_lukuo.setText(""+trafficLIghts_api.get);
        holder.te_red.setText("红灯"+trafficLIghts_api.getRedTime());
        holder.te_green.setText("绿灯"+trafficLIghts_api.getGreenTime());
        holder.te_Yollowr.setText("黄灯"+trafficLIghts_api.getYellowTime());
        holder.te_lukuo.setText("路口"+i);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class TrafficLights extends RecyclerView.ViewHolder {
        private TextView te_lukuo,te_red,te_Yollowr,te_green;
        public TrafficLights(@NonNull View itemView) {
            super(itemView);
            te_lukuo=itemView.findViewById(R.id.te_lukuo);
            te_red=itemView.findViewById(R.id.te_red);
            te_Yollowr=itemView.findViewById(R.id.te_Yollowr);
            te_green=itemView.findViewById(R.id.te_green);
        }
    }
}
